package top.timous;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

/**
 * spring框架的配置类
 */
@Configuration // 表示当前类是配置类
// 组件扫描器不扫描我们的controller
@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ANNOTATION , classes = Controller.class))
@EnableTransactionManagement
public class SpringConfig {


    @Bean
    public PlatformTransactionManager transactionManager(DataSource dataSource){
        DataSourceTransactionManager dstm = new DataSourceTransactionManager();
        dstm.setDataSource(dataSource);
        return dstm;
    }
//    @Bean
//    public DataSource dataSource(){
//        DataSource dataSource = new BasicDataSource();
//        return dataSource;
//    }


//    /**
//     * 跨域问题配置   全局的
//     * @return
//     */
//    @Bean
//    public CrossFilter corsFilter() {
//        return new CrossFilter();
//    }
//


}
